{{extend 'layout.html'}}

<div id="content" style="background-color:white;">

<h2>Report For:</h2>
{{=form}}
</br>
<table border="1">
<tr>
<th>Date</th><th>Segment</th><th>Start Time</th><th>Pledge Goal</th><th>Dollar Goal</th><th>Pledges Over/Under Goal</th><th>Dollars Over/Under Goal</th><th>Average Pledge</th><th>Total Pledges</th><th>Total Dollars</th>
</tr>
{{for ct, s in enumerate(seg_dicts):}}
	{{dtime=str(s['start_time']).split()}}
	<tr>
	<td>{{=dtime[0]}}</td><td>{{=s['title']}}</td><td>{{=dtime[1]}}</td>
	{{if s['goal_type'] == 'Pledge':}}
		{{pledgediff = (s['total_pledges']-s['goal'])}}
		<td>{{=s['goal']}}</td>
		<td>n/a</td>
		{{if pledgediff == 0:}}
			<td>{{=pledgediff}}</td>
		{{elif pledgediff <= 0:}}
			<td><span style="color:#DF0101">{{=pledgediff}}</span></td>
		{{else:}}
			<td><span style="color:#04B404">{{=pledgediff}}</span></td>
		{{pass}}
		<td>n/a</td>
	{{else:}}
		{{dollardiff = (s['total_dollars']-s['goal'])}}
		<td>n/a</td>
		<td>{{=s['goal']}}</td>
		<td>n/a</td>
		{{if dollardiff == 0:}}
			<td>{{=dollardiff}}</td>
		{{elif dollardiff <= 0:}}
			<td><span style="color:#DF0101">{{=dollardiff}}</span></td>
		{{else:}}
			<td><span style="color:#04B404">{{=dollardiff}}</span></td>
		{{pass}}
	{{pass}}
	{{if s['total_pledges'] > 0:}}
		<td>{{=s['total_dollars']/s['total_pledges']}}</td>
	{{else:}}
		<td>{{=0}}</td>
	{{pass}}
	<td>{{=s['total_pledges']}}</td>
	<td>{{=s['total_dollars']}}</td>
	</tr>
{{pass}}
</table>

<h2>Total Dollars: ${{=total_dollars}}</h2>
<h2>Total Pledges: {{=total_pledges}}</h2>
{{if total_pledges > 0:}}
	<h2>Average Pledge Amount: ${{=total_dollars/total_pledges}}</h2>
{{else:}}
	<h2>Average Pledge Amount: $0</h2>
{{pass}}
</div>
